package com.ql.mangersystem.controller;

import com.ql.mangersystem.common.HoneyLogs;
import com.ql.mangersystem.common.LogType;
import com.ql.mangersystem.common.Result;
import com.ql.mangersystem.entity.dto.PersonDTO;
import com.ql.mangersystem.service.UserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RequestMapping("/person")
@RestController
@Slf4j
@Api("个人信息接口")
@CrossOrigin(value = "http://localhost:5173/")
public class PersonController {
    @Resource
    private UserService userService;

    @ApiOperation("修改个人信息")
    @PostMapping("/edit")
    @HoneyLogs(operation = "个人信息",type = LogType.UPDATE)
    public Result edit(@RequestBody PersonDTO personDTO) {
        int result = userService.edit(personDTO);
        if (result <=0) {
            return Result.error("修改失败");
        }
        return Result.success();
    }
}
